package GUI;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import msgParser.Message;
import msgParser.Strings;
import Core.Connection;
/*
 * Made By: Kudinov Roma
 * 2013
 * 
 */
class ActivationDialog implements ActionListener 
{
    public void actionPerformed(ActionEvent e)
    {
    	JPanel p = new JPanel();
    	p.setLayout(null);
    	JButton activate = new JButton("Activate");
    	activate.setBounds(90, 150, 130, 30);
    	final JTextField tf1 = new JTextField();
    	final JTextField tf2 = new JTextField();
    	JLabel title = new JLabel("Activate Account");
    	title.setBounds(70, 15, 300, 20);
    	title.setFont(new Font(title.getFont().getName(),title.getFont().getStyle(), 18));
    	final JLabel userName = new JLabel("User name:");
    	userName.setBounds(20, 60, 100, 30);
    	final JLabel code = new JLabel("Activation code:");
    	code.setBounds(20, 110, 100, 30);
    	tf1.setBounds(120, 60, 130, 30);
    	tf2.setBounds(120, 110, 130, 30);
    	p.add(tf1);
    	p.add(tf2);
    	p.add(activate);
    	p.add(userName);
    	p.add(code);
    	p.add(title);
    	JDialog jd = new JDialog();
    	jd.setTitle("Account Activation");
    	jd.add(p);
    	jd.setBounds(200, 290, 300, 230);
    	jd.setResizable(false);
    	jd.setVisible(true);
    	activate.addActionListener(
    	new ActionListener() 
    	{
    		public void actionPerformed(ActionEvent e)
    		{
    			Connection.send(Message.createMessage(Strings.ACTIVATION_REQUEST, tf1.getText(), tf2.getText()));
    		}
    	});
							            
    }
}